<template>
  <div>
    <video ref="videoPlayer" class="video-js vjs-big-play-centered" @play="handleStartPlay"></video>
  </div>
</template>

<script>
  import videojs from 'video.js';

  export default {
    name: "VideoPlayer",
    props: {
      options: {
        type: Object,
        default() {
          return {};
        }
      }
    },
    data() {
      return {
        player: null
      }
    },
    mounted() {
      this.player = videojs(this.$refs.videoPlayer, this.options, function onPlayerReady() {
      })
    },
    methods: {
      handleStartPlay(){
        this.$store.state.audio.isPlayingFlag = false;
      }
    },
    beforeDestroy() {
      if (this.player) {
        this.player.dispose()
      }
    }
  }
</script>

<style lang="scss">
  .video-js .vjs-big-play-button {
    font-size: 2.5em;
    line-height: 2.3em;
    height: 2.5em;
    width: 2.5em;
    -webkit-border-radius: 2.5em;
    -moz-border-radius: 2.5em;
    border-radius: 2.5em;
    background-color: #73859f;
    background-color: rgba(200, 200, 200, 0.3);
    border-width: 0.15em;
    margin-top: -1.25em;
    margin-left: -1.25em;
  }

  /* 中间的播放箭头 */
  .vjs-big-play-button .vjs-icon-placeholder {
    font-size: 1.63em;
  }

  /* 加载圆圈 */
  .vjs-loading-spinner {
    font-size: 2.5em;
    width: 2em;
    height: 2em;
    border-radius: 1em;
    margin-top: -1em;
    margin-left: -1em;
  }

  /*暂停时显示大播放按钮*/
  .vjs-paused .vjs-big-play-button, .vjs-paused.vjs-has-started .vjs-big-play-button {
    display: block;
  }
</style>
